<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
	<link rel='stylesheet' type='text/css' href='../ext-3.3.0/resources/css/ext-all.css' />
		<script type='text/javascript' src='../ext-3.3.0/adapter/ext/ext-base.js'></script>
		<script type='text/javascript' src='../ext-3.3.0/ext-all-debug.js'></script>

<link rel='stylesheet' type='text/css'
	href='../calendar/resources/css/calendar.css' />
<script type='text/javascript' src='../calendar/calendar-all-debug.js'></script>

<script type='text/javascript'>
    var editWin;
	var calendarStore = new Ext.data.JsonStore( {
		storeId : 'calendarStore',
		root : 'calendars',
		idProperty : 'id',
		data : {
			"calendars" : [ {
				"id" : 1,
				"title" : "Home"
			}, {
				"id" : 2,
				"title" : "Work"
			}, {
				"id" : 3,
				"title" : "School"
			} ]
		},
		proxy : new Ext.data.MemoryProxy(),
		autoLoad : true,
		fields : [ {
			name : 'CalendarId',
			mapping : 'id',
			type : 'int'
		}, {
			name : 'Title',
			mapping : 'title',
			type : 'string'
		} ],
		sortInfo : {
			field : 'CalendarId',
			direction : 'ASC'
		}
	});

	 function showEditWindow(rec){
        if(!editWin){
            editWin = new Ext.Window({
               // calendarStore: calendarStore,
               closeAction: 'hide',
				listeners: {
					'eventadd': {
						fn: function(win, rec){
							alert(0);
							win.hide();
							rec.data.IsNew = false;
							this.eventStore.add(rec);
                            this.showMsg('Event '+ rec.data.Title +' was added');
						},
						scope: this
					},
					'eventupdate': {
						fn: function(win, rec){
						alert(1);
						//	win.hide();
							//rec.commit();
                          //  this.showMsg('Event '+ rec.data.Title +' was updated');
						},
						scope: this
					},
					'eventdelete': {
						fn: function(win, rec){
						alert(2);
							//this.eventStore.remove(rec);
							//win.hide();
                           // this.showMsg('Event '+ rec.data.Title +' was deleted');
						},
						scope: this
					},
                    'editdetails': {
                        fn: function(win, rec){
						alert(3);
                            win.hide();
                           // App.calendarPanel.showEditForm(rec);
                        }
                    }
				}
            });
        }
       // alert(rec);
        editWin.show();
	}
		
	function showMsg(msg) {
		Ext.fly('app-msg').update(msg).removeClass('x-hidden');
	}

	function clearMsg() {
		Ext.fly('app-msg').update('').addClass('x-hidden');
	}

	Ext.onReady(function() {
		Date.monthNames = [ '1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月',
				'9月', '10月', '11月', '12月' ];
		Date.dayNames = [ '周日', '周一', '周二', '周三', '周四', '周五', '周六' ];
		Ext.BLANK_IMAGE_URL = '../ext-3.3.0/resources/images/default/s.gif';
		Ext.chart.Chart.CHART_URL = '../ext-3.3.0/resources/charts.swf';
		Ext.QuickTips.init();

		${ExtJS.script}
	});
</script>
</head>
<body>
<span id="app-msg" class="x-hidden"></span>
</body>
</html>